package com.k2data.k2app.service.pas14;


import com.k2data.k2app.common.MyConstant;
import com.k2data.k2app.exception.K2ResponseException;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 从pas取回来的数据
 * Created by clb on 17-3-30.
 */
@Log4j2
@Service
public class Pas14Basic {
	@Autowired
	private MyConstant myConstant;

	public String getMqSuffix(){ return myConstant.getMqSuffix();}
	public String getOwner () {
		return myConstant.getOwner();
	}
	public String getCreator(){
		return myConstant.getCreator();
	}

	public String getProjectUrl (){
		return myConstant.getService()+"projects";
	}
	public String getServiceBasic(){
		String service = myConstant.getService();
		return service.substring(0,service.indexOf("pas")-1);
	}
	public String getRunJobUrl(Long projId){
		return myConstant.getService()+"projects/run/"+projId;
	}

	public String getJobsUrl(){
		return myConstant.getService()+"jobs";
	}
	public String getResultUrl(){
		return myConstant.getService()+"results";
	}
	public String getDownLoadUrl(Long modelId,String fileName){
		return myConstant.getService()+"file/download?projId="+modelId+"&fileName="+fileName;
	}
	public String getHdfsDownLoadUrl(String filepath,String fileName){
		return myConstant.getService()+"hdfs/download?filePath="+filepath+"&fileName="+fileName;
	}
	public String getHdfsUrl(){
		return myConstant.getService()+"hdfs/browse";
	}

	/**
	 * 拼接pas url
	 * @param url
	 * @return
	 */
	public String getURI(String url) throws K2ResponseException {
		return myConstant.getURI(url);
	}

	/**
	 * 拼接查询条件
	 * @param params
	 * @return
	 */
	public String getQueryCondition(Map<String,Object> params){
		return myConstant.getQueryCondition(params);
	}
}
